package cn.xzqwjw.taskmanager.domain.pojo;

import cn.xzqwjw.taskmanager.common.validator.ValidGroupUpdate;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.List;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author rush
 */
@TableName(value = "t_category")
@EqualsAndHashCode(callSuper = true)
@Data
public class Category extends Model<Category> implements Serializable {

  @TableField(exist = false)
  private static final long serialVersionUID = 1L;

  @Override
  public Serializable pkVal() {
    return this.id;
  }

  @TableId(value = "id", type = IdType.AUTO)
  @NotNull(message = "id不能为空", groups = ValidGroupUpdate.class)
  private Integer id;

  @NotBlank(message = "tag不能为空！")
  @Length(min = 1, max = 20, message = "tag长度应为1到20")
  private String tag;

  @NotNull(message = "父id不能为空")
  private Integer idParent;

  @NotNull(message = "depth不能为空")
  private Integer depth;

  @NotNull(message = "weight不能为空")
  private Integer weight = 99;

  @NotBlank(message = "label 不能为空！")
  @Length(min = 1, max = 20, message = "label 长度应为1到20")
  private String label;

  @NotNull(message = "flagSystem不能为空")
  private Integer flagSystem = 0;

  private String urlCoverImg = "";

  /**
   * 子类别
   */
  @TableField(exist = false)
  private List<Category> childCategoryList;

}